package com.test.demo.controller;

import com.test.demo.entity.User;
import com.test.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/users")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/master")
    public List<User> getMasterUsers() {
        return userService.getUsersFromMaster();
    }

    @GetMapping("/slave")
    public List<User> getSlaveUsers() {
        return userService.getUsersFromSlave();
    }

    @PostMapping
    public boolean addUser(@RequestBody User user) {
        return userService.save(user);
    }

    @GetMapping("/get")
    public List<User> get() {
        return userService.get();
    }

} 